/*
 * Copyright 2012 Alain Pannetrat (L1L1@gmx.com)
 * 
 * This file is part of cookie-miner.
 * 
 * cookie-miner is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * cookie-miner is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with cookie-miner. If not, see http://www.gnu.org/licenses/.
 *
 * @version: $Id$
 *
 */
#ifndef LOG_FACILITY_H
#define LOG_FACILITY_H
#include <cstdio>
#include <cstdarg>
#include <time.h>
#include <sys/types.h> 
#include <unistd.h>
#include <cstdio>
#include <pthread.h>

class log_facility {
	public:
		enum {
			LOG_ALL,
			LOG_DEBUG,
			LOG_WARNING,
			LOG_ERROR,
			LOG_NONE
		};

		log_facility(FILE *logfile = stderr);
		
		log_facility& message(unsigned level, const char *format, ...);

		void verbosity(unsigned level)  { _level = level; }
		
		void new_thread();

		~log_facility(); 
	private:
		FILE *_log;
		unsigned _level;
		pthread_key_t 	_thread_key;
		static bool	_thread_key_registered;
};

extern log_facility logger;
#endif
